package SimpleFactory;

public class Factory {
    //方法1
    public static Car getCar(String name){
        if (name.equals("特斯拉")){
            return new Tesla(name);
        }else if (name.equals("五菱")){
            return new Wuling(name);
        }else {
            System.out.println("没有此车");
            return null;
        }
    }

 /*
   //方法2
    public static Car getTesla(){
        return new Tesla("特斯拉");
    }

    public static Car getWuling(){
        return new Tesla("五菱");
    }
    */
}
